
package com.zcp.wizard;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;

public class TipActivity extends Activity {
    private View.OnClickListener listener = null;

    private OnCheckedChangeListener checkListener = null;

    private CheckBox checkNext;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tip);

        listener = new View.OnClickListener() {

            public void onClick(View v) {
                onClickNext();
            }
        };
        ((Button) findViewById(R.id.nextTip)).setOnClickListener(listener);
        checkNext = (CheckBox) findViewById(R.id.checkNext);
        TextView checkNextText = (TextView) findViewById(R.id.checkNextText);

        checkListener = new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // buttonView.setTextColor(isChecked ? getResources().getColor(
                // R.color.checkbox_checked) : getResources().getColor(
                // R.color.checkbox_normal));

                SharedPreferences share = getApplicationContext().getSharedPreferences(
                        Constants.WIZARD_SETTINGS, Context.MODE_PRIVATE);
                Editor edit = share.edit();
                edit.putInt(Constants.DONT_SHOW_TIPS, isChecked ? 1 : 0);
                edit.commit();
            }
        };

        checkNext.setOnCheckedChangeListener(checkListener);

        checkNextText.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                checkNext.setChecked(!checkNext.isChecked());
            }
        });
    }

    private void onClickNext() {
        Intent intent = new Intent(this, MyTabActivity.class);
        this.startActivity(intent);
        this.finish();
        overridePendingTransition(R.anim.zoomin, R.anim.zoomout); // 此为自定义的动画效果，下面两个为系统的动画效果
    }

    @Override
    public void onDestroy() {
        checkListener = null;
        listener = null;
        super.onDestroy();
    }
}
